package com.example.controller.adm;

import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import com.example.pojo.VehiclePy;
import com.example.service.IVehiclePyService;
import io.swagger.annotations.Api;
/**
 * <p>
 * 车辆申请表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-05-06
 */
@RestController
@RequestMapping("/process/vehicle-py")
@Api(tags = "车辆申请表",value = "")
@CrossOrigin(allowCredentials = "true")
public class VehiclePyController {

    @Autowired
    private IVehiclePyService vehiclePyService;

    @ApiOperation(value = "查询车辆申请表")
    @GetMapping("/query")
    public ResultVo queryAllVehiclePy(String empName){
        return vehiclePyService.queryAllVehiclePy(empName);
    };

    @ApiOperation(value = "创建车辆申请")
    @PostMapping("/add")
    public ResultVo addVehiclePy(@RequestBody VehiclePy vehiclePy) {
        return vehiclePyService.createVehiclePy(vehiclePy);
    }

    @ApiOperation(value = "同意车辆申请")
    @PutMapping("/update")
    public ResultVo updateStatus(@RequestBody VehiclePy vehiclePy) {
        if (vehiclePyService.updateById(vehiclePy)){
            return ResultVo.success("修改成功。");
        }
        return ResultVo.error("修改失败!");
    }

    @ApiOperation(value = "查询车辆申请列表的车辆")
    @GetMapping("/vehicle-list")
    public ResultVo queryVehicleList(){
        return vehiclePyService.queryVehicleList();
    }

//    @ApiOperation(value = "删除车辆申请表")
//    @DeleteMapping("/delete")
//    public ResultVo deleteVehiclePy(Integer[] ids){
//        if(vehiclePyService.removeByIds(Arrays.asList(ids))){
//            return ResultVo.ok();
//        }
//        return ResultVo.error();
//    }
}
